package cn.edu.zjut.mina.xcmahjong;

import org.apache.mina.core.session.IoSession;

import cn.edu.zjut.mina.bean.RoomInfo_XCMJ;
import cn.edu.zjut.mina.bean.StandardFormat;
import cn.edu.zjut.mina.util.UserSessionMap;

public class XcmjService {
	static UserSessionMap usm = UserSessionMap.getInstance();

	public static void doGang(StandardFormat inJson, IoSession session) {
		String roomId = inJson.roomId;
		int position = inJson.position;
		RoomInfo_XCMJ roomInfo = (RoomInfo_XCMJ) usm.get(roomId);
		roomInfo.getGame().players[position].doGang(inJson, session);
	}

	// 自摸明杠
	public static void doZimoMingGang(StandardFormat inJson, IoSession session) {
		String roomId = inJson.roomId;
		int position = inJson.position;
		RoomInfo_XCMJ roomInfo = (RoomInfo_XCMJ) usm.get(roomId);
		roomInfo.getGame().players[position].doZimoMingGang(inJson, session);
	}

	// 自摸暗杠
	public static void doZimoAnGang(StandardFormat inJson, IoSession session) {
		String roomId = inJson.roomId;
		int position = inJson.position;
		RoomInfo_XCMJ roomInfo = (RoomInfo_XCMJ) usm.get(roomId);
		roomInfo.getGame().players[position].doZimoAnGang(inJson, session);
	}

	public static void doPeng(StandardFormat inJson, IoSession session) {
		String roomId = inJson.roomId;
		int position = inJson.position;
		RoomInfo_XCMJ roomInfo = (RoomInfo_XCMJ) usm.get(roomId);
		roomInfo.getGame().players[position].doPeng(inJson, session);
	}

	public static void doHu(StandardFormat inJson, IoSession session) {
		String roomId = inJson.roomId;
		int position = inJson.position;
		RoomInfo_XCMJ roomInfo = (RoomInfo_XCMJ) usm.get(roomId);
		roomInfo.getGame().players[position].doHu(inJson, session);
	}

	public static void disCard(StandardFormat inJson, IoSession session) {
		String roomId = inJson.roomId;
		int position = inJson.position;
		RoomInfo_XCMJ roomInfo = (RoomInfo_XCMJ) usm.get(roomId);
		roomInfo.getGame().players[position].doDiscard(inJson, session);
	}

	 public static void doPass(StandardFormat inJson,IoSession session){
		 String roomId=inJson.roomId;
		 int position=inJson.position;
		 RoomInfo_XCMJ roomInfo=(RoomInfo_XCMJ) usm.get(roomId);
		 roomInfo.getGame().players[position].doPass(inJson, session);
	 }
	public static void hpgQueue(StandardFormat inJson, IoSession session) {
		String roomId = inJson.roomId;
		RoomInfo_XCMJ roomInfo = (RoomInfo_XCMJ) usm.get(roomId);
		roomInfo.getGame().hpgQueue(inJson, session);
	}
}
